package wrs.hcs.tc;

import org.openqa.selenium.WebDriver;

import wrs.hcs.functions.AdminConsole;
import wrs.hcs.functions.AdminConsole_Pair;
import wrs.hcs.functions.AdminConsole_Tracker;
import wrs.hcs.functions.Hcs_Admission;
import wrs.hcs.functions.Hcs_Billing;
import wrs.hcs.functions.Hcs_NewPatient;
import wrs.hcs.functions.Hcs_Nursing;
import wrs.hcs.functions.Login;
import wrs.hcs.functions.Logout;
import wrs.hcs.functions.Miscellaneous;
import wrs.hcs.functions.Webdriver;

public class WebAdmin_SingleWithPin {

	public static WebDriver driver;
	public static String lName, lName1, lName2;
	public static String pin, pin1, pin2;
	
	static
	Webdriver d = new Webdriver();
	Login log = new Login();
	Logout out = new Logout();
	AdminConsole console = new AdminConsole();
	AdminConsole_Tracker act = new AdminConsole_Tracker();
	Miscellaneous m = new Miscellaneous();
	Hcs_Admission adm = new Hcs_Admission();
	Hcs_NewPatient newPatient = new Hcs_NewPatient();
	Hcs_Nursing pack = new Hcs_Nursing();
	Hcs_Billing bill = new Hcs_Billing();
	AdminConsole_Pair acp = new AdminConsole_Pair();
	
	public void transact() throws Exception
	{
		driver = d.startUp();
		
		//Criteria for login in hcs: "admission", "nursing", "billing"
		log.hcs(driver, "admission"); 											//login to hcs

		String getIt = newPatient.createPatient(driver, "adult");				//new patient in hcs
		out.hcs(driver); 														//logout after getting pin and lastname
		
		//Split string for PIN and LASTNAME
		String[] arrString = getIt.split(",");
		lName = arrString[0];
		pin = arrString[1];
		
		log.admin(driver); 														//login to wrs admin console
		console.create_single_inpatient_with_pin_in_admin(driver,pin, "private");
		
		String mainWindow = console.window_main_focus(driver);
		console.wellness_search_it(driver, pin, "", "");
		console.get_status_and_click(driver, pin, false);
		String text = m.set_dropdown_to_hcs("queue");
		console.select_dropdown_to_hcs(driver, text, "single");
		driver.switchTo().window(mainWindow);
		console.display_message_to_hcs(driver);
		console.wellness_search_it(driver, pin, "", "");
		console.get_status_and_click(driver, "", false);
		act.goto_result_tracker(driver);
		act.tracker(driver, pin);
		out.admin(driver);
		
		log.hcs(driver, "admission");
		adm.update_admission(driver, pin);
		out.hcs(driver);
		
		log.hcs(driver, "nursing");
		pack.validate(driver, pin); 											//validate package of patient
		pack.discharge(driver, pin); 											//fill up discharge instructions
		pack.pf(driver, pin); 													//assign pf and discharge
		out.hcs(driver);
		log.hcs(driver, "billing"); 											//das discharge
		bill.regular(driver, pin); 
		out.hcs(driver);
		log.hcs(driver, "nursing"); 											//print gatepass
		pack.gatepass(driver, pin);
		out.hcs(driver);

	}
		
	public void outpatient() throws Exception
	{
		driver = d.startUp();
		//Criteria for login in hcs: "admission", "nursing", "billing"
		log.hcs(driver, "admission"); 											//login to hcs
		String getIt = newPatient.createPatient(driver, "adult");				//new patient in hcs
		out.hcs(driver); 														//logout after getting pin and lastname
		
		//Split string for PIN and LASTNAME
		String[] arrString = getIt.split(",");
		lName = arrString[0];
		pin = arrString[1];
		
		log.admin(driver); 														//login to wrs admin console
		console.create_single_inpatient_with_pin_in_admin(driver,pin,"opd");

		String mainWindow = console.window_main_focus(driver);
		console.wellness_search_it(driver, pin, "", "");
		console.get_status_and_click(driver, pin, false);
		String text = m.set_dropdown_to_hcs("outpatient");
		console.select_dropdown_to_hcs(driver, text, "single");
		driver.switchTo().window(mainWindow);
		console.display_message_to_hcs(driver);
		console.wellness_search_it(driver, pin, "", "");
		console.get_status_and_click(driver, "", false);
		//act.goto_result_tracker(driver);
		//act.tracker(driver, pin);
		out.admin(driver);
		
		log.hcs(driver, "admission");
		adm.update_admission(driver, pin);
		out.hcs(driver);
		
		log.hcs(driver, "nursing");
		pack.validate(driver, pin); 											//validate package of patient
		pack.discharge(driver, pin); 											//fill up discharge instructions
		pack.pf(driver, pin); 													//assign pf and discharge
		out.hcs(driver);
		log.hcs(driver, "billing"); 											//das discharge
		bill.regular(driver, pin); 
		out.hcs(driver);
		log.hcs(driver, "nursing"); 											//print gatepass
		pack.gatepass(driver, pin);
		out.hcs(driver);
	}
	
	public void pair() throws Exception{
		driver = d.startUp();
		
		//Criteria for login in hcs: "admission", "nursing", "billing"
		log.hcs(driver, "admission"); 											//login to hcs
		String getIt = newPatient.createPatient(driver, "adult");				//new patient in hcs
		out.hcs(driver); 														//logout after getting pin and lastname
				
		//Split string for PIN and LASTNAME
		String[] arrString = getIt.split(",");
		lName1 = arrString[0];
		pin1 = arrString[1];
		
		//Criteria for login in hcs: "admission", "nursing", "billing"
		log.hcs(driver, "admission"); 											//login to hcs
		getIt = newPatient.createPatient(driver, "adult");						//new patient in hcs
		out.hcs(driver); 														//logout after getting pin and lastname
						
		//Split string for PIN and LASTNAME
		String[] arrStrings = getIt.split(",");
		lName2 = arrStrings[0];
		pin2 = arrStrings[1];
		
		log.admin(driver); 														//login to wrs admin console
		acp.pair(driver, pin1, pin2);
		out.admin(driver);
		
		//ADMIT PATIENT 1 to 10thnw
		log.hcs(driver, "admission");
		adm.update_admission(driver, pin1);
		out.hcs(driver);
		//ADMIT PATIENT 2 to 10thnw
		log.hcs(driver, "admission");
		adm.update_admission(driver, pin2);
		out.hcs(driver);
		//VALIDATE PATIENT 1 ON NURSING UNIT
		log.hcs(driver, "nursing");
		pack.validate(driver, pin1); 											//validate package of patient
		pack.discharge(driver, pin1); 											//fill up discharge instructions
		pack.pf(driver, pin1); 													//assign pf and discharge
		out.hcs(driver);
		//VALIDATE PATIENT 2 ON NURSING UNIT
		log.hcs(driver, "nursing");
		pack.validate(driver, pin2); 											//validate package of patient
		pack.discharge(driver, pin2); 											//fill up discharge instructions
		pack.pf(driver, pin2); 													//assign pf and discharge
		out.hcs(driver);
		//BILL DISCHARGE PATIENT 1
		log.hcs(driver, "billing");
		bill.regular(driver, pin1); 
		out.hcs(driver);
		//BILL DISCHARGE PATIENT 2
		log.hcs(driver, "billing");
		bill.regular(driver, pin2); 
		out.hcs(driver);
		
	}
	
	public void tracker() throws Exception{
		
		driver = d.startUp();
		
		//Criteria for login in hcs: "admission", "nursing", "billing"
		log.hcs(driver, "admission"); 											//login to hcs

		String getIt = newPatient.createPatient(driver, "adult");				//new patient in hcs
		out.hcs(driver); 														//logout after getting pin and lastname
		
		//Split string for PIN and LASTNAME
		String[] arrString = getIt.split(",");
		lName = arrString[0];
		pin = arrString[1];
		
		log.admin(driver); 														//login to wrs admin console
		console.create_single_inpatient_with_pin_in_current_date(driver,pin, "private");
		
		String mainWindow = console.window_main_focus(driver);
		console.wellness_search_it(driver, pin, "", "");
		console.get_status_and_click(driver, pin, false);
		String text = m.set_dropdown_to_hcs("tracker");
		console.select_dropdown_to_hcs(driver, text, "single");
		driver.switchTo().window(mainWindow);
		console.display_message_to_hcs(driver);
		console.wellness_search_it(driver, pin, "", "");
		console.get_status_and_click(driver, "", false);
		act.goto_result_tracker(driver);
		act.tracker(driver, pin);
		out.admin(driver);
		driver.close();
	}
}
